package utils;


import obj.*;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 工具类
 */
public class GameUtils {

    //背景图片
    //public static Image bgImg = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/bg.jpg").getPath());
    public static Image bgImg;
    public static Image bg1Img;
    public static Image bossImg ;
    public static Image boss1Img ;
    //我方战斗机图片
    public static Image palneImg ;
    //我方子弹图片
    public static Image shellImg ;
    //敌方子弹图片
    public static Image bulletImg ;
    //敌方战斗机图片
    public static Image enemtImg ;
    //我方飞机爆炸图片
    public static Image explode1Img ;
    static {
        try {
            bgImg = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/bg.jpg").openStream());
            bg1Img = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/bg1.jpg").openStream());
            bossImg = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/boss.png").openStream());
            boss1Img = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/boss1.png").openStream());
            palneImg = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/me1.png").openStream());

            shellImg = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/bullet2.png").openStream());
            bulletImg = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/bullet1.png").openStream());
            enemtImg = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/enemy2.png").openStream());
            explode1Img = ImageIO.read(GameUtils.class.getClassLoader().getResource("imgs/me_destroy_3.png").openStream());


        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /*public static Image bg1Img = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/bg1.jpg").getPath());
    public static Image bossImg = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/boss.png").getPath());
    public static Image boss1Img = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/boss1.png").getPath());
    //我方战斗机图片
    public static Image palneImg = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/me1.png").getPath());
    //我方子弹图片
    public static Image shellImg = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/bullet2.png").getPath());
    //敌方子弹图片
    public static Image bulletImg = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/bullet1.png").getPath());
    //敌方战斗机图片
    public static Image enemtImg = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/enemy2.png").getPath());
    //我方飞机爆炸图片
    public static Image explode1Img = Toolkit.getDefaultToolkit().getImage(GameUtils.class.getClassLoader().getResource("imgs/me_destroy_3.png").getPath());*/

    //所有游戏物体的集合
    public static List<GameObj> gameObjList = new ArrayList<>();

    //要删除元素的集合
    public static List<GameObj> removeList = new ArrayList<>();
    //我方子弹的集合
    public static List<ShellObj> shellObjList = new ArrayList<>();
    //敌方子弹的集合
    public static List<BulletObj> bulletObjList = new ArrayList<>();

    //敌方飞机的集合
    public static List<EnemyObj> enemyObjList = new ArrayList<>();
    //爆炸的集合
    public static List<ExplodeObj> explodeObjList = new ArrayList<>();

    //绘制字符串的工具类
    public static void drawWord(Graphics gImages,String str,Color color,int size,int x,int y) {
        gImages.setColor(color);
        gImages.setFont(new Font("仿宋",Font.BOLD,size));
        gImages.drawString(str,x,y);
    }
}
